# Maintainer: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>

_pkgname=znc
pkgname=${_pkgname}-git
pkgver=r5083.65bce1c5
pkgrel=1
pkgdesc='An IRC bouncer with modules & scripts support'
url='https://znc.in/'
license=('Apache 2.0')
arch=('i686' 'x86_64')
provides=('znc')
conflicts=('znc')
depends=('openssl')
makedepends=('cyrus-sasl'
             'gettext-devel'
             'git'
             'icu-devel'
             'libsasl-devel'
             'perl'
             'python'
             'swig'
             #'tcl'
             )
optdepends=('tcl: modtcl module'
            'python: modpython module'
            'perl: modperl module'
            'cyrus-sasl: cyrusauth module')
source=('znc::git+https://github.com/znc/znc#branch=master'
        'znc-configure-msys2.patch')
sha256sums=('SKIP'
            '8371060182875ee36ac82c86a398ed8b1283c4e4b872bee4994d004fa8a808c3')

pkgver() {
  cd "${srcdir}/${_pkgname}"
  echo "r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${_pkgname}"

  patch -p1 -i ${srcdir}/znc-configure-msys2.patch
  git submodule update --init --recursive
  ./autogen.sh
}

build() {
  cd "${srcdir}/znc"
  ./configure --prefix=/usr \
    --enable-cyrus \
    --disable-tcl \
    --enable-perl \
    --enable-python
  make
}

package() {
  cd "${srcdir}/znc"
  make DESTDIR="${pkgdir}" install
  install -Dm644 LICENSE ${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE
}
